package com.lagou.edu.utils;

import com.alibaba.druid.pool.DruidDataSource;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author 应癫
 */
public class DruidUtils {

    private DruidUtils(){
    }

    private static DruidDataSource druidDataSource = new DruidDataSource();


    static {
        InputStream inStream = DruidUtils.class.getClassLoader().getResourceAsStream("jdbc.properties");

        Properties prop = new Properties();
        try {
            prop.load(inStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        druidDataSource.setDriverClassName(String.valueOf(prop.get("jdbc.driver")));
        druidDataSource.setUrl(String.valueOf(prop.get("jdbc.url")));
        druidDataSource.setUsername(String.valueOf(prop.get("jdbc.username")));
        druidDataSource.setPassword(String.valueOf(prop.get("jdbc.password")));

    }

    public static DruidDataSource getInstance() {
        return druidDataSource;
    }

}
